#!/bin/bash
declare -a arr=(Debug Release)
MACHINE_TYPE=`uname -m`
mkdir -p ../Linux/
INSTALL_DIR=`readlink -f ../Linux/`/
for i in ${arr[@]}
do
    if [ ${MACHINE_TYPE} == 'x86_64' ]; then
        mkdir -p ${INSTALL_DIR}x86_64/$i
        mkdir -p ${INSTALL_DIR}x86_64/$i/lib
        mkdir -p ${INSTALL_DIR}x86_64/$i/include
        mkdir -p x86_64/$i
        cd x86_64/$i
        cmake ../../
        make -j16
        cp -R -f *.a ${INSTALL_DIR}x86_64/$i/lib/
        cp -R -f ../../include/* ${INSTALL_DIR}x86_64/$i/include/
        cd ../../
        mkdir -p ${INSTALL_DIR}x86/$i 
        mkdir -p ${INSTALL_DIR}x86/$i/lib
        mkdir -p ${INSTALL_DIR}x86/$i/include
        mkdir -p x86/$i
        cd x86/$i
        LDFLAGS=-m32 CFLAGS=-m32 CXXFLAGS=-m32 cmake ../../
        make -j16
        cp -R -f *.a ${INSTALL_DIR}x86/$i/lib/
        cp -R -f ../../include/* ${INSTALL_DIR}x86/$i/include/
        cd ../../
    else
        mkdir -p ${INSTALL_DIR}x86/$i
        mkdir -p ${INSTALL_DIR}x86/$i/lib
        mkdir -p ${INSTALL_DIR}x86/$i/include
        mkdir -p x86/$i
        cd x86/$i
        cmake ../../
        make -j16
        cp -R -f *.a ${INSTALL_DIR}x86/$i/lib/
        cp -R -f ../../include/* ${INSTALL_DIR}x86/$i/include/
        cd ../../
    fi
done
